# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libplist
pkgver=2.1.0
pkgrel=0
pkgdesc="A library to handle Apple Property List format whereas it's binary or XML"
url="https://libimobiledevice.org/"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="py3-setuptools swig python3-dev glib-dev cython
	automake autoconf libtool"
subpackages="$pkgname-static $pkgname-dev py3-$pkgname:_py3 $pkgname-util $pkgname++:cxx"
source="$pkgname-$pkgver.tar.gz::https://github.com/libimobiledevice/libplist/archive/$pkgver.tar.gz"

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man
	make
}

check() {
	# https://github.com/libimobiledevice/libplist/issues/118
	case "$CARCH" in
		arm*) return 0;;
	esac

	make check -j1 # https://github.com/libimobiledevice/libimobiledevice/issues/777
}

package() {
	make DESTDIR="$pkgdir" install
}

util() {
	pkgdesc="Util for libplist"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

_py3() {
	pkgdesc="Python bindings for libplist"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

cxx() {
	pkgdesc="C++ bindings to libplist"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*++.so.* "$subpkgdir"/usr/lib/
}

sha512sums="c06a500c16775974e48a503fa484849a96e2aed50c18cab2a4002f92a64a22b20fb6fee991ac115dc4e55d7d7894d8e9f30c35ea96bc4ade943de031559d7453  libplist-2.1.0.tar.gz"
